{% extends 'base_ajgl.html' %}
{% load staticfiles %}
{% block title %}
    <title>河南省农业行政执法案件管理平台-{{ request.user }}</title>
{% endblock %}
{% block css %}
    <link rel="stylesheet" href="/static/sweetalert/sweetalert.css">
    <script src="/static/sweetalert/sweetalert.js"></script>
    <style>
        td, th {
            text-align: center
        }

        .mytd1 {
            min-width: 90px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd2 {
            min-width: 70px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd3 {
            max-width: 220px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd4 {
            max-width: 100px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .mytd1 > a, .mytd2 > a, .mytd3 > a, .mytd4 > a {
            text-decoration: none;
        }

        tr.zt1 td a:not(.btn) {
            color: #da4453
        }
    </style>
{% endblock %}

{% block body %}
    <div class="container" style="padding: 0;margin-top: 20px">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">
                    案件列表
                </h3>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th> 立案时间</th>
                            <th> 所属地区</th>
                            <th> 当事人</th>
                            <th> 案由</th>
                            <th> 案件类型</th>
                            <th> 涉案金额</th>
                            <th> 处罚金额</th>
                            <th> 案件状态</th>
                            <th> 操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for foo in list %}
                            <tr class="zt{{ foo.aj_zhuangtai }}">
                                <td>
                                    <div class="mytd1"><a href="/jie/{{ foo.id }}/">{{ foo.aj_time1 }}</a></div>
                                </td>
                                <td>
                                    <div class="mytd1"><a href="/jie/{{ foo.id }}/">{{ foo.shi }} {{ foo.xian }}</a>
                                    </div>
                                </td>
                                <td>
                                    <div class="mytd4"><a href="/jie/{{ foo.id }}/">{{ foo.aj_dangshiren }}</a></div>
                                </td>
                                <td>
                                    <div class="mytd3"><a href="/jie/{{ foo.id }}/">{{ foo.aj_anyou }}</a></div>
                                </td>
                                <td>
                                    <div class="mytd2"><a
                                            href="/jie/{{ foo.id }}/">{{ foo.get_aj_zhonglei_display }}</a></div>
                                </td>
                                <td>
                                    <div class="mytd2"><a href="/jie/{{ foo.id }}/">{{ foo.aj_sheanjine|default:0 }}</a>
                                    </div>
                                </td>
                                <td>
                                    <div class="mytd2"><a href="/jie/{{ foo.id }}/">{{ foo.aj_chufajine }}</a></div>
                                </td>
                                <td>
                                    <div class="mytd1"><a
                                            href="/jie/{{ foo.id }}/">{{ foo.get_aj_zhuangtai_display }}</a></div>
                                </td>
                                <td>
                                    <a class="btn btn-danger btn-sm del" role="button" pid="{{ foo.id }}">删除</a>
                                </td>
                            </tr>
                        {% endfor %}

                        </tbody>
                    </table>
                    <ul class="pagination pagination-sm pull-right">
                        {{ page_obj.page_str|safe }}
                    </ul>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block js %}
    <script>
    $('.pagination ').append('<li><a href="/download/aj/"><span class="glyphicon glyphicon-download-alt"></span></a></li>')
        $(".del").click(function () {
            pid = $(this).attr("pid")
            tr = $(this).parents('tr')
            swal({
                    title: "确定要删除吗?",
                    text: "删除将不可恢复!",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonClass: "btn-danger",
                    confirmButtonText: "删了吧!",
                    cancelButtonText: "不删了",
                    closeOnConfirm: false,
                },
                function () {
                    $.ajax({
                        url: "/del_aj/" + pid + "/",
                        type: "get",
                        dataType: "json",
                        success: function (arg) {
                            if (arg.status == 1) {
                                tr.remove();
                                swal("已经删除!", "案件已经被删除，你可以跑路了！", "success");
                            } else {
                                swal("删除失败!", "您删除的案件不存在,或权限不足！", "success");
                            }

                        }
                    })
                });
        })
    </script>
{% endblock %}



